package com.ayuku.commons;

import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
/**
 * 
 * @author putu kusuma <putukn@gmail.com>
 *
 */
public class CommonUtil {
	static final String encryptionKey = "123456789012345678901234567890";

	private CommonUtil() {
	}

	public static String[] split() {
		return null;
	}

	public static String bytes2String(byte[] bytes) {
		StringBuffer stringBuffer = new StringBuffer();

		for (int i = 0; i < bytes.length; i++) {
			stringBuffer.append((char) bytes[i]);
		}

		return stringBuffer.toString();
	}

	public static void doShellCenter(Display display, Shell shell) {
		Monitor primary = display.getPrimaryMonitor();
		Rectangle bounds = primary.getBounds();
		Rectangle rect = shell.getBounds();
		int x = bounds.x + (bounds.width - rect.width) / 2;
		int y = bounds.y + (bounds.height - rect.height) / 2;
		shell.setLocation(x, y);
	}

	public static void doDailyReservCenter(Shell shell) {
		Monitor primary = shell.getDisplay().getPrimaryMonitor();
		Rectangle bounds = primary.getBounds();
		int x = bounds.x + (bounds.width - 1000) / 2;
		int y = bounds.y + (bounds.height - (700 + 20)) / 2;
		shell.setLocation(x, y);
	}

	public static void doSize(Shell shell) {
		Monitor primary = shell.getDisplay().getPrimaryMonitor();
		Rectangle bounds = primary.getBounds();
		int x = bounds.x + (bounds.width - 1000) / 2;
		int y = bounds.y + (bounds.height - (700 + 20)) / 2;
		shell.setLocation(x, y);
	}

}
